﻿<Window x:Class="QueryWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MaxWidth="800" MinHeight="300"
        xmlns:system="clr-namespace:System;assembly=mscorlib" 
        xml:lang="fr-FR"
    Title="Requete" SizeToContent="WidthAndHeight" Width="600" Height="400">
    <Window.Resources>
        <Style TargetType="ComboBox">
            <Setter Property="Background" Value="White" />
        </Style>
        <DataTemplate x:Key="ValueCellEditingTemplate">
            <TextBox Text="{Binding SimpleValue, Mode=TwoWay}" />
        </DataTemplate>
        <Style TargetType="{x:Type TabItem}">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="Background" Value="White" />

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
                            <ContentPresenter Margin="5" x:Name="Content" ContentSource="Header" HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Panel.ZIndex" Value="1"/>
                                <Setter Property="Background" Value="Black"/>
                                <Setter Property="Foreground" Value="White"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="{x:Type TabControl}">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabControl}">
                        <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="ColumnDefinition0"/>
                                <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                                <RowDefinition x:Name="RowDefinition1" Height="*"/>
                            </Grid.RowDefinitions>
                            <UniformGrid Rows="1"  x:Name="HeaderPanel" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
                            <Border x:Name="ContentPanel" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
                                <ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>
    <Grid Margin="5">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="3" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Button Click="AddSourceButton_Click" Background="White" Padding="5" Content="Add Source" Margin="2" />
            <ComboBox Name="SourceComboBox" Padding="5" Margin="2" Grid.Row="1" DisplayMemberPath="Name" />
            <TreeView Name="ColonnesTreeView" Grid.Row="2"  >
                <TreeView.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" />
                    </DataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
        </Grid>

        <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  />
        <TabControl Grid.Column="2">
            <TabItem Header="Selectionner">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <DataGrid AutoGenerateColumns="False" Name="SelectionDataGrid" ColumnWidth="*"  >
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Colonne" Binding="{Binding Path=Name, Mode=TwoWay}" />
                            <DataGridComboBoxColumn Header="Formule" SelectedItemBinding="{Binding Path=Formula, Mode=TwoWay}" DisplayMemberPath="Formula" />
                            <DataGridComboBoxColumn  Header="Aggregation"  SelectedItemBinding="{Binding Path=Aggregate, Mode=TwoWay}" >
                                <DataGridComboBoxColumn.ItemsSource>
                                    <x:Array Type="{x:Type system:String}">
                                        <system:String>(Aucun)</system:String>
                                        <system:String>Somme</system:String>
                                        <system:String>Moyenne</system:String>
                                        <system:String>Minimum</system:String>
                                        <system:String>Maximum</system:String>
                                        <system:String>Variance</system:String>
                                        <system:String>Ecart-Type</system:String>
                                        <system:String>Nombre</system:String>
                                    </x:Array>
                                </DataGridComboBoxColumn.ItemsSource>
                            </DataGridComboBoxColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                    <CheckBox Name="DistinctCheckBox" Grid.Row="1" Margin="5" FontSize="14" Content="Selectionner les lignes distinctes"  Padding="1" VerticalContentAlignment="Center" />
                </Grid>
            </TabItem>
            <TabItem Header="Filtrer">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="5" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <DataGrid Name="FilterDataGrid" AutoGenerateColumns="False" ColumnWidth="*">
                        <DataGrid.Columns>
                            <DataGridComboBoxColumn Header="Colonne" SelectedItemBinding="{Binding Path=Row, Mode=TwoWay}" DisplayMemberPath="Name" />
                            <DataGridComboBoxColumn Header="Operateur" SelectedItemBinding="{Binding Path=Operator, Mode=TwoWay}"  >
                                <DataGridComboBoxColumn.ItemsSource>
                                    <x:Array Type="{x:Type system:String}">
                                        <system:String>Egal</system:String>
                                        <system:String>Different</system:String>
                                        <system:String>Superieur ou Egal</system:String>
                                        <system:String>Superieur</system:String>
                                        <system:String>Inferieur ou Egal</system:String>
                                        <system:String>Inferieur</system:String>
                                        <system:String>Est Contenu Dans</system:String>
                                        <system:String>Comme</system:String>
                                        <system:String>Contient</system:String>
                                        <system:String>Commence Par</system:String>
                                        <system:String>Termine Par</system:String>
                                    </x:Array>
                                </DataGridComboBoxColumn.ItemsSource>
                            </DataGridComboBoxColumn>
                            <DataGridTemplateColumn Header="Valeur" CellEditingTemplate="{StaticResource ValueCellEditingTemplate}" >
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <!--<TextBlock DataContext="{Binding Value}" Text="{Binding StringValue}" />-->
                                        <TextBlock Text="{Binding SimpleValue}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridComboBoxColumn Header="Operateur" SelectedItemBinding="{Binding Path=BooleanOperator, Mode=TwoWay}"  >
                                <DataGridComboBoxColumn.ItemsSource>
                                    <x:Array Type="{x:Type system:String}">
                                        <system:String>ET</system:String>
                                        <system:String>OU</system:String>
                                    </x:Array>
                                </DataGridComboBoxColumn.ItemsSource>
                            </DataGridComboBoxColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                    <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                    <DataGrid ColumnWidth="*" AutoGenerateColumns="False"  Grid.Row="2" Name="OriginalFilterDataGrid">
                        <DataGrid.Columns>
                            <DataGridComboBoxColumn Header="Colonne" SelectedItemBinding="{Binding Path=OriginalRow, Mode=TwoWay}" />
                            <DataGridComboBoxColumn Header="Operateur" SelectedItemBinding="{Binding Path=Operator, Mode=TwoWay}"  >
                                <DataGridComboBoxColumn.ItemsSource>
                                    <x:Array Type="{x:Type system:String}">
                                        <system:String>Egal</system:String>
                                        <system:String>Different</system:String>
                                        <system:String>Superieur ou Egal</system:String>
                                        <system:String>Superieur</system:String>
                                        <system:String>Inferieur ou Egal</system:String>
                                        <system:String>Inferieur</system:String>
                                        <system:String>Est Contenu Dans</system:String>
                                        <system:String>Comme</system:String>
                                        <system:String>Contient</system:String>
                                        <system:String>Commence Par</system:String>
                                        <system:String>Termine Par</system:String>
                                    </x:Array>
                                </DataGridComboBoxColumn.ItemsSource>
                            </DataGridComboBoxColumn>
                            <DataGridTemplateColumn Header="Valeur" CellEditingTemplate="{StaticResource ValueCellEditingTemplate}" >
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <!--<TextBlock DataContext="{Binding Value}" Text="{Binding StringValue}" />-->
                                        <TextBlock Text="{Binding SimpleValue}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridComboBoxColumn Header="Operateur" SelectedItemBinding="{Binding Path=BooleanOperator, Mode=TwoWay}"  >
                                <DataGridComboBoxColumn.ItemsSource>
                                    <x:Array Type="{x:Type system:String}">
                                        <system:String>ET</system:String>
                                        <system:String>OU</system:String>
                                    </x:Array>
                                </DataGridComboBoxColumn.ItemsSource>
                            </DataGridComboBoxColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
            <TabItem Header="Trier">
                <DataGrid Name="SortDataGrid" AutoGenerateColumns="False" ColumnWidth="*" >
                    <DataGrid.Columns>
                        <DataGridComboBoxColumn Header="Colonne" SelectedItemBinding="{Binding Path=Row, Mode=TwoWay}" DisplayMemberPath="Name" />
                        <DataGridComboBoxColumn Header="Direction" SelectedItemBinding="{Binding Path=Direction, Mode=TwoWay}"  >
                            <DataGridComboBoxColumn.ItemsSource>
                                <x:Array Type="{x:Type system:String}">
                                    <system:String>Croissant</system:String>
                                    <system:String>Decroissant</system:String>
                                </x:Array>
                            </DataGridComboBoxColumn.ItemsSource>
                        </DataGridComboBoxColumn>
                    </DataGrid.Columns>
                </DataGrid>
            </TabItem>
            <TabItem Header="Options">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <UniformGrid Rows="3" Columns="2"  Margin="5" VerticalAlignment="Center"  >
                        <RadioButton IsChecked="True" Margin="5"  GroupName="OutputOption" Content="Stocker Dans une Table" />
                        <TextBox  Margin="5" />
                        <RadioButton  Margin="5"  GroupName="OutputOption" Content="Stocker Dans une Table Temporaire" />
                        <TextBox  Margin="5"  />
                        <RadioButton  Margin="5"  GroupName="OutputOption" Content="Stocker Dans une Variable" />
                        <TextBox  Margin="5"  />
                    </UniformGrid>
                    <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                    <UniformGrid Grid.Row="2" Margin="5" Columns="2" >
                        <Button Name="PreviewSqlButton" Content="Previsualiser le code SQL" Padding="5" Background="White" Margin="5" />
                        <Button Name="PreviewDataButton" Content="Previsualiser les donnes" Padding="5" Background="White" Margin="5" />
                    </UniformGrid>
                    <TabControl Grid.Row="3">
                        <TabItem Name="PreviewSqlTabItem" Header="Preview Sql TabItem">
                            <TextBox Name="PreviewSqlTextBox" AcceptsReturn="True" AcceptsTab="True">

                            </TextBox>
                        </TabItem>
                        <TabItem Name="PreviewDataTabItem" Header="Preview Data TabItem">
                            <DataGrid Name="PreviewDataGrid" IsReadOnly="True"  />
                        </TabItem>
                    </TabControl>


                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
